package com.chinar.funds;

public class FundPosition {
    private String stockCode;       // 股票代码
    private String stockName;       // 股票名称
    private String latestPrice;     // 最新价
    private String changePercent;   // 涨跌幅
    private String holdingShares;   // 持股数
    private String changeValue;     // 涨跌值（计算得出）

    /**
     * 构造函数
     * @param stockCode 股票代码
     * @param stockName 股票名称
     * @param latestPrice 最新价
     * @param changePercent 涨跌幅
     * @param holdingShares 持股数
     * @param changeValue 涨跌值
     */
    public FundPosition(String stockCode, String stockName, String latestPrice, 
                       String changePercent, String holdingShares, String changeValue) {
        this.stockCode = stockCode;
        this.stockName = stockName;
        this.latestPrice = latestPrice;
        this.changePercent = changePercent;
        this.holdingShares = holdingShares;
        this.changeValue = changeValue;
    }

    // Getters and Setters
    public String getStockCode() {
        return stockCode;
    }

    public void setStockCode(String stockCode) {
        this.stockCode = stockCode;
    }

    public String getStockName() {
        return stockName;
    }

    public void setStockName(String stockName) {
        this.stockName = stockName;
    }

    public String getLatestPrice() {
        return latestPrice;
    }

    public void setLatestPrice(String latestPrice) {
        this.latestPrice = latestPrice;
    }

    public String getChangePercent() {
        return changePercent;
    }

    public void setChangePercent(String changePercent) {
        this.changePercent = changePercent;
    }

    public String getHoldingShares() {
        return holdingShares;
    }

    public void setHoldingShares(String holdingShares) {
        this.holdingShares = holdingShares;
    }

    public String getChangeValue() {
        return changeValue;
    }

    public void setChangeValue(String changeValue) {
        this.changeValue = changeValue;
    }

    // 为了与item_fund_position.xml布局文件中的ID对应，提供这些别名方法
    public String getDate() {
        return stockCode;
    }

    public String getNetValue() {
        return stockName;
    }

    public String getEstimate() {
        return latestPrice;
    }

    public String getGrowthRate() {
        return changePercent;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        
        FundPosition that = (FundPosition) obj;
        
        if (stockCode != null ? !stockCode.equals(that.stockCode) : that.stockCode != null)
            return false;
        if (stockName != null ? !stockName.equals(that.stockName) : that.stockName != null)
            return false;
            
        return true;
    }

    @Override
    public int hashCode() {
        int result = stockCode != null ? stockCode.hashCode() : 0;
        result = 31 * result + (stockName != null ? stockName.hashCode() : 0);
        return result;
    }
}